package cn.wolfcode.trip.base.domain;


import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
/**
 * 攻略的分类
 */
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends BaseDomain{

    public static final Boolean STATE_NORMAL = true; //正常
    public static final Boolean STATE_DISABLE = false; //禁用

    //分类名称
    private String name;
    //分类所属哪个大攻略
    private Strategy strategy;
    //序号
    private Integer sequence;
    //攻略分类的状态
    private Boolean state = STATE_NORMAL;

    //维护攻略分类跟攻略文章 多对一的关系
    private List<StrategyDetail> details = new ArrayList<StrategyDetail>();


    public String getStateName(){
        if(state!=null){
            return state?"启用":"禁用";
        }
        return "";
    }

    public String getJSONString(){
        Map<String,Object> map = new HashMap<String,Object>();

        map.put("id",id );
        map.put("name",name );
        map.put("sequence",sequence );
        map.put("state",state );
        if(strategy!=null){
            map.put("strategyId",strategy.id );
        }

        return JSONUtils.toJSONString(map);

    }



}